/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package model.creature.monster.plugin;

import java.awt.Image;
import model.creature.monster.DefaultFullyFunctionalMonster;
import model.creature.moving_creature.ActionType;
import model.creature.moving_creature.Direction;
import model.game.GameInterface;
import model.map.cell.Cell;
import model.utility.ImageUtility;

/**
 * Aims at sprites. Can step on unsteppable cells.
 */
public class Ninja extends DefaultFullyFunctionalMonster {

  /**
   * Constructor
   */
  public Ninja(GameInterface game, Cell cell) {
    super(game, cell);
  }

  @Override
  public boolean canStepOnUnsteppableCells() {
    return true;
  }

  @Override
  public int getSpeed() {
    return 2;
  }

  @Override
  public int getMaxHP() {
    return 300;
  }

  @Override
  public String getName() {
    return "Ninja";
  }

  @Override
  public String getDescription() {
    return "Attacks your sprites";
  }

  @Override
  public Image getImage() {
    return ImageUtility.loadImage("resources/pictures/monster/ninja/ninja.png");
  }

  @Override
  public int getPower() {
    return 50;
  }

  @Override
    protected int howImportantIsFacingThis(model.map.cell.Cell cell) {
      if (!game_.getCreatures().getSprites().getAllSpritesAt(cell).isEmpty()) {
        return 2;
      }
      if (game_.getCreatures().getCrystals().containsCrystalAt(cell)) {
        return 1;
      }
      return 0;
    }

  @Override
  protected ActionType getActionType(Cell cell, Direction dir) {
    Cell front = game_.getMaps().getCellInFrontOff(cell, dir);
    if (!game_.getCreatures().getSprites().getAllSpritesAt(front).isEmpty()) {
        return ActionType.kActionHostileAttack;
      }
    if (game_.getCreatures().getCrystals().containsCrystalAt(front)) {
      return ActionType.kActionHostileAttack;
    }
    //random movement
    return ActionType.getMoveFromDirection(Direction.valueOf(rand_.nextInt(4)));

  }

}
